#include "RenderStage.h"

namespace devii
{

RenderStage::RenderStage(Pipeline* const pipeline)
{
	this->pipeline = pipeline;
}


RenderStage::~RenderStage()
{
}

void RenderStage::init(const unsigned int width, const unsigned int height)
{
	vp.Height = (float)height;
	vp.Width = (float)width;
	vp.MinDepth = 0.0f;
	vp.MaxDepth = 1.0f;
	vp.TopLeftX = 0;
	vp.TopLeftY = 0;
}

void RenderStage::clear()
{
	float clear[4] = {1.0f, 0.0f, 0.0f, 1.0f};
	for(unsigned int i = 0; i < render_targets.size(); i++)
	{
		pipeline->clearRenderTarget(clear, render_targets[i]);
	}

}

void RenderStage::render(const matrix& view_proj)
{
	pipeline->setRenderTarget(render_targets.size(), &render_targets[0], NULL);
	pipeline->setViewports(1, &vp);


	for(unsigned int i = 0; i < box_models.size(); i++)
	{
		box_models[i]->prepare(view_proj);

		pipeline->draw(0,6);
	}

}

}